<template>
  <!--退卡工单-->
  <div class="tuika">
    <div class="search">
      <input type="text" placeholder="搜索" v-model="queryContent">
      <img src="../../assets/search.png" alt="" width="16" @click="goSearch()">
    </div>
    <div class="page-infinite-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }">
      <wv-group
        v-infinite-scroll="getList"
        infinite-scroll-disabled="loading"
        infinite-scroll-distance="10"
      >
        <wv-tabs v-model="activeIndex" class="container" @click="goSearch()">
          <wv-tab title="全部">
            <!--1已提交,2取消提交,3退卡专员审核中,4退卡专员审核拒绝,5退卡专员审核通过,6退款专员专员审核中,7退款专员审核拒绝,8退款专员审核通过,9退款专员已退款,10财务经理审核拒绝,11财务经理审核通过-->
            <ul class="list">
              <li v-for="item in backCardRecordList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.isCheck==-2">现办现退失败</span>
                    <span class="status" v-if="item.isCheck==-1">现办现退中</span>
                    <span class="status" v-if="item.isCheck==0">现办现退成功</span>
                    <span class="status" v-if="item.isCheck==1">已提交</span>
                    <span class="status" v-if="item.isCheck==2">取消提交</span>
                    <span class="status" v-if="item.isCheck==3">退卡专员审核中</span>
                    <span class="status" v-if="item.isCheck==4">退卡专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==5">退卡专员审核通过</span>
                    <span class="status" v-if="item.isCheck==6">退款专员审核中</span>
                    <span class="status" v-if="item.isCheck==7">退款专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==8">退款专员审核通过</span>
                    <span class="status" v-if="item.isCheck==9">退款专员已退款</span>
                    <span class="status" v-if="item.isCheck==10">财务经理审核拒绝</span>
                    <span class="status" v-if="item.isCheck==11">财务经理审核通过</span>
                  </li>
                  <li><p><span>申请时间：{{item.subDate}}</span><br><span v-if="item.isCheck==2"></span></p>
                    <wv-button type="default" :mini="true" class="lookdetail" v-if="item.isCheck==1"
                               @click="goCancelTuika(item.backcardRecordId)">取消提交
                    </wv-button>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
          <wv-tab title="退卡中">
            <ul class="list">
              <li v-for="item in backCardRecordList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.isCheck==0">现办现退</span>
                    <span class="status" v-if="item.isCheck==1">已提交</span>
                    <span class="status" v-if="item.isCheck==2">取消提交</span>
                    <span class="status" v-if="item.isCheck==3">退卡专员审核中</span>
                    <span class="status" v-if="item.isCheck==4">退卡专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==5">退卡专员审核通过</span>
                    <span class="status" v-if="item.isCheck==6">退款专员审核中</span>
                    <span class="status" v-if="item.isCheck==7">退款专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==8">退款专员审核通过</span>
                    <span class="status" v-if="item.isCheck==9">退款专员已退款</span>
                    <span class="status" v-if="item.isCheck==10">财务经理审核拒绝</span>
                    <span class="status" v-if="item.isCheck==11">财务经理审核通过</span>
                  </li>
                  <li><p><span>申请时间：{{item.subDate}}</span><br><span v-if="item.isCheck==2">取消说明：由客户专员1314发起</span></p>
                    <wv-button type="default" :mini="true" class="lookdetail" v-if="item.isCheck==1">取消提交</wv-button>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
          <wv-tab title="退卡完成">
            <ul class="list">
              <li v-for="item in backCardRecordList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.isCheck==0">现办现退</span>
                    <span class="status" v-if="item.isCheck==1">已提交</span>
                    <span class="status" v-if="item.isCheck==2">取消提交</span>
                    <span class="status" v-if="item.isCheck==3">退卡专员审核中</span>
                    <span class="status" v-if="item.isCheck==4">退卡专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==5">退卡专员审核通过</span>
                    <span class="status" v-if="item.isCheck==6">退款专员审核中</span>
                    <span class="status" v-if="item.isCheck==7">退款专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==8">退款专员审核通过</span>
                    <span class="status" v-if="item.isCheck==9">退款专员已退款</span>
                    <span class="status" v-if="item.isCheck==10">财务经理审核拒绝</span>
                    <span class="status" v-if="item.isCheck==11">财务经理审核通过</span>
                  </li>
                  <li><p><span>申请时间：{{item.subDate}}</span><br><span v-if="item.isCheck==2">取消说明：由客户专员1314发起</span></p>
                    <wv-button type="default" :mini="true" class="lookdetail" v-if="item.isCheck==1">取消提交</wv-button>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
          <wv-tab title="取消退卡">
            <ul class="list">
              <li v-for="item in backCardRecordList">
                <ul>
                  <li>{{item.mobile}} <span>{{item.userName}}</span>
                    <span class="status" v-if="item.isCheck==0">现办现退</span>
                    <span class="status" v-if="item.isCheck==1">已提交</span>
                    <span class="status" v-if="item.isCheck==2">取消提交</span>
                    <span class="status" v-if="item.isCheck==3">退卡专员审核中</span>
                    <span class="status" v-if="item.isCheck==4">退卡专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==5">退卡专员审核通过</span>
                    <span class="status" v-if="item.isCheck==6">退款专员审核中</span>
                    <span class="status" v-if="item.isCheck==7">退款专员审核拒绝</span>
                    <span class="status" v-if="item.isCheck==8">退款专员审核通过</span>
                    <span class="status" v-if="item.isCheck==9">退款专员已退款</span>
                    <span class="status" v-if="item.isCheck==10">财务经理审核拒绝</span>
                    <span class="status" v-if="item.isCheck==11">财务经理审核通过</span>
                  </li>
                  <li><p><span>申请时间：{{item.subDate}}</span><br><span v-if="item.isCheck==2">取消说明：{{item.remarkb}}</span>
                  </p>
                    <wv-button type="default" :mini="true" class="lookdetail" v-if="item.isCheck==1">取消提交</wv-button>
                  </li>
                </ul>
              </li>
            </ul>
          </wv-tab>
        </wv-tabs>
      </wv-group>
    </div>
    <router-link to="/tuikatijiao" tag="p" class="offer"><img src="../../assets/xinjian.png" alt="" width="18">新建
    </router-link>
  </div>
</template>

<script type="text/ecmascript-6">
  import {getTuikaData, cancelTuika} from '../../../test/unit/http'
  import {Toast} from 'we-vue'

  export default {
    name: '',
    props: {},
    data() {
      return {
        activeIndex: 0,
        backCardRecordList: [],
        queryContent: '',
        wrapperHeight: 0,
        page: 1,
        rows: 10,
        loading: false,
        pages: 0,
        totalNum: 0
      };
    },
    methods: {
      goSearch() {
        this.backCardRecordList = [];
        this.page = 1;
        this.getList();
      },
      getData(params) {
        this.loading = true;
        getTuikaData(params).then(res => {
          console.log(res);
          if (res.code == 100) {
            let data = res.object;
            let list = data.rows;
            let pages = data.pages;
            let page = data.page;
            this.page = page;
            this.pages = pages;
            let totalNum = data.totalNum;
            this.totalNum = totalNum;
            if (list.length > 0) {
              this.backCardRecordList = this.backCardRecordList.concat(list);
            }
            if (this.page < this.pages) {
              this.page++;
              this.loading = false
            } else {
              this.loading = true
            }
          } else {
            Toast.text(res.info);
          }
        })
      },
      getList() {
        let params = {};
        let activeIndex = this.activeIndex;
        if (activeIndex == 1) {
          params['isCheck'] = 1;
        }
        if (activeIndex == 2) {
          params['isCheck'] = 9;
        }
        if (activeIndex == 3) {
          params['isCheck'] = 2;
        }
        params['page'] = this.page;
        params['rows'] = this.rows;
        params['queryContent'] = this.queryContent;
        this.getData(params)
      },
      goCancelTuika(backcardRecordId) {
        cancelTuika({backcardRecordId: backcardRecordId}).then(res => {
          console.log(res);
          if (res.code == 100) {
            this.page == 1;
            this.backCardRecordList = [];
            this.getList()
          }
        })
      }
    },
    created() {
    },
    components: {}
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .search {
    position: relative;
    width: 95%;
    margin: 10px auto;

    input {
      width: 90%;
      border: 1px solid #eee;
      box-shadow: 0 3px 4px rgba(17, 17, 17, 0.05);
      border-radius: 7px;
      height: 25px;
      line-height: 25px;
      padding: 10px;
      color: #111;
    }

    img {
      position: absolute;
      right: 20px;
      top: 16px;
    }
  }

  .list {
    padding-bottom: 70px;

    > li {
      margin: 15px 10px;
      text-align: left;
      border-bottom: 1px solid #ddd;

      li {
        margin-bottom: 10px;
      }

      li:first-child {
        font-size: 16px;
        color: #111;
        font-weight: 700;

        span {
          color: #999;
          margin-left: 10px;
        }

        .status {
          font-size: 13px;
          float: right;
          font-weight: normal;
        }
      }

      li:last-child {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        .lookdetail {
          background-color: #fff;
          border: 1px solid #f98e3c;
          color: #f98e3c;
        }

        p {
          flex: 1;
        }
      }
    }

    > li:last-child {
      border-bottom: none;
    }

  }

  .offer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: #f98e3c;
    height: 50px;
    line-height: 50px;
    color: #fff;

    img {
      vertical-align: middle;
      margin-right: 5px;
    }
  }
</style>
